import 'dart:convert';
import 'package:cloud_medicine/components/util.dart';
import 'package:cloud_medicine/http/HttpUtil.dart';
import 'package:cloud_medicine/http/config.dart';
import 'package:dio/dio.dart';

// 获取医生列表
Future getDoctorList_api(String url) async {
  String token = await getToken();
  Response res = await HttpUtil.request(
    url,
    method: HttpUtil.GET,
    headers: {'Authorization': token},
  );
  return jsonDecode(res.data);
}

// 发起会话
Future sendDiscuss_api(Map<String, dynamic> data) async {
  String token = await getToken();
  Response res = await HttpUtil.request(
    '$backIP/doctor/catch',
    method: HttpUtil.POST,
    parameters: data,
    headers: {'Authorization': token},
  );
  return jsonDecode(res.data);
}

// 改变医生状态
Future alterDoctorStatus_api(Map<String, dynamic> data) async {
  String token = await getToken();
  Response res = await HttpUtil.request(
    '$backIP/doctor/status',
    method: HttpUtil.PUT,
    parameters: data,
    headers: {'Authorization': token},
  );
  return jsonDecode(res.data);
}